package com.example.weather;

import org.json.JSONObject;


import com.thinkland.sdk.android.DataCallBack;
import com.thinkland.sdk.android.JuheData;
import com.thinkland.sdk.android.Parameters;
import com.thinkland.sdk.android.SDKInitializer;

import android.support.v7.app.ActionBarActivity;
import android.app.Application;
import android.os.Bundle;
import android.provider.CalendarContract.Instances;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView.FindListener;
import android.widget.TextView;
import android.widget.Toast;


public class MainActivity extends ActionBarActivity {
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		final TextView tv = (TextView) findViewById(R.id.tv);

		
		Parameters params = new Parameters();
			
		 params.add("cityname", "西安");
		 params.add("dtype", "json");
		
		
		 JuheData.executeWithAPI(73, "http://op.juhe.cn/onebox/weather/query",
		 JuheData.GET,params, new DataCallBack() {
		 @Override
		 public void resultLoaded(int err, String reason, String result) {
		 if (err == 0) {
		 tv.setText(result);
		 } else {
		 Toast.makeText(getApplicationContext(), reason,
		 Toast.LENGTH_SHORT).show();
		 }
		 }
		 });
		

	}
}
